package org.brisling.oa.queryService;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.servlet.http.HttpServletResponse;

import org.brisling.base.domain.ChartDomain;
import org.brisling.base.domain.ListDomain;
import org.brisling.base.domain.RetDomain;
import org.brisling.common.ConstSysParam;
import org.brisling.oa.domain.OADrugStatisticAudit;
import org.brisling.oa.domain.OAEquipmentOverhaul;
import org.brisling.oa.queryService.base.AbstractOAQueryService;
import org.brisling.sysman.queryService.QueryDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

@RestController
@RequestMapping("/oaEquipmentOverhaul/query")
/**
 * 
 * <p>
 * Title: QueryOAEquipmentOverhaulService
 * </p>
 * <p>
 * Description: 设备大修查询服务类
 * </p>
 * <p>
 * Company: 长沙东勤信息科技发展有限公司
 * </p>
 * 
 * @author jackson wang
 * @since 1.0
 * @version 1.0
 * @date 2017年7月25日 上午10:59:39
 */
public class QueryOAEquipmentOverhaulService extends AbstractOAQueryService<OAEquipmentOverhaul> {

	@Autowired
	private QueryDictionaryService dicService;

	// 模块业务编码
	private String moduleCode = "oaEquipmentOverhaul";

	private String printName = "设备大修审批单";

	public QueryOAEquipmentOverhaulService() {
		this.moduleName = ConstSysParam.MODULE_OA_EQUIPMENT_OVERHAUL;
		this.subSystem = ConstSysParam.SUBSYSTEM_OA;
		this.tableName = ConstSysParam.VIEW_PREFIX + this.moduleName;
		this.clazz = OAEquipmentOverhaul.class;

		typeMap = this.getTypeMap(clazz);

		// orderMap.put("bizno",null);

	}

	@PersistenceContext(unitName = ConstSysParam.SUBSYSTEM_SYSMAN)
	@Autowired
	protected void setEntityManager(EntityManager entityManager) {
		this.entityManager = entityManager;
	}

	@RequestMapping("/mainPage.action")
	public ModelAndView getMainPage() {
		return this.getBizMainPage();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.brisling.service.sysman.DepartmentServiceInf#getEditPage()
	 */
	@RequestMapping("/editPage.action")
	public ModelAndView getEditPage() {
		return this.getBizEditPage();
	}

	@RequestMapping("/getListDomain.action")
	public ListDomain<OAEquipmentOverhaul> getListDomain(@RequestBody(required = false) String body) {

		return super.getListDomain(body);
	}

	@RequestMapping("/getOperateTaskListDomain.action")
	public ListDomain<OAEquipmentOverhaul> getUserCanoperateTask(@RequestBody(required = false) String body) {
		return super.getUserCanoperateTask(body);
	}

	@RequestMapping("/getSignedTaskListDomain.action")
	public ListDomain<OAEquipmentOverhaul> getUserSignedTask(@RequestBody(required = false) String body) {

		return super.getUserSignedTask(body);
	}

	@RequestMapping("/getUnsignedTaskListDomain.action")
	public ListDomain<OAEquipmentOverhaul> getUserUnsignedTask(@RequestBody(required = false) String body) {
		return super.getUserUnsignedTask(body);
	}

	@RequestMapping("/getFinishedTaskListDomain.action")
	public ListDomain<OAEquipmentOverhaul> getUserFinishedTask(@RequestBody(required = false) String body) {
		return super.getUserFinishedTask(body);
	}

	@RequestMapping("/getAllTaskListDomain.action")
	public ListDomain<OAEquipmentOverhaul> getAllTask(@RequestBody(required = false) String body) {
		return super.getAllTask(body);
	}

	@RequestMapping("/getUserManagedTaskDomain.action")
	public ListDomain<OAEquipmentOverhaul> getUserManagedTask(@RequestBody(required = false) String body) {
		return super.getUserManagedTask(body);
	}

	// @RequestMapping("/exportExcel.action")
	// public void exportExcel(@RequestBody(required=false) String
	// body,HttpServletResponse response){
	// String title = "设备维修";
	// String sqlid = "medical_inquiry_export";
	// super.exportExcel(body, response,title,sqlid);
	// }

	@RequestMapping("/getTaskListDomain.action")
	public ListDomain<OAEquipmentOverhaul> getTaskListDomain(@RequestBody(required = false) String body) {

		return super.getTaskListDomain(body);
	}

	/**
	 * 获取任务数量
	 * 
	 * @return
	 */
	@RequestMapping("/getTaskCnt.action")
	public List<ChartDomain> getTaskCnt(@RequestBody(required = false) String body) {

		return super.getTaskCnt(body);

	}

	/**
	 * 根据用户id查找用户信息
	 * 
	 * @param id
	 *            用户id
	 * @return 用户信息记录
	 */
	@RequestMapping("/getOne.action")
	public OAEquipmentOverhaul getOne(@RequestParam(value = "id", required = false) Long id) {
		return super.getOne(id);
	}

	/**
	* 根据唯一编码查找业务记录
	 * @param identify 唯一编码
	 * @return 业务记录
	 */
	@RequestMapping("/getOneByIdentify.action")
	public OAEquipmentOverhaul getOneByIdentify(@RequestParam(value = "identify", required = false) String identify) {
		return super.getOneByIdentify(identify);
	}

	/**
	 * 根据指定字段名及字段值查找记录
	 * @param field		字段名
	 * @param fieldVal	字段值
	 * @return
	 */
	@RequestMapping("/getOneByField.action")
	public OAEquipmentOverhaul getOneByField(@RequestParam(value = "field", required = false) String field,
			@RequestParam(value = "fieldVal", required = false) String fieldVal) {
		return super.getOneByIdentify(field, fieldVal);
	}
	
	/**
	 * 根据指定字段名及字段值查找记录
	 * @param field		字段名
	 * @param fieldVal	字段值
	 * @return
	 */
	@RequestMapping("/getOneByBizTable.action")
	public OAEquipmentOverhaul getOneByBizTable(@RequestParam(value="field",required=false) String field,
			@RequestParam(value="fieldVal",required=false) String fieldVal){	
		return super.getOneByTable(field,fieldVal);
	}

	/**
	 * 返回流程记录流程实例的执行记录
	 * 
	 * @param body
	 *            包含procInstId在内的参数信息
	 * @return
	 */

	@RequestMapping("/flowHistoricsListDomain.action")
	public ListDomain<Object> getHistoricByProcInstId(@RequestBody(required = false) String body) {

		String sql = dicService.getSqlByBizcode("flow_historics");
		return super.getHistoricByProcInstId(body, sql);
	}

	/**
	 * 根据业务记录id查找维修信息
	 * 
	 * @param id
	 *            记录id
	 * @return 维修记录
	 */
	@RequestMapping("/exportWord.action")
	public RetDomain exportWord(@RequestParam(value = "id", required = false) Long id, HttpServletResponse response) {
		return super.exportWord(id, moduleCode, response, printName);
	}

	public String generateBizno() {
		return super.generateBizno();
	}

	public List<OAEquipmentOverhaul> getAllList(String sql) {
		return super.getAllList(sql);
	}
}
